﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace hse_2013_test_dima_sasha
{
    internal class FileDataProvider
    {

        public FileDataProvider(string filename)
        {
            string question;
            Answers[] ListOfAnswers;
            int checkerOfType;
            bool result;
            StreamReader sr = new StreamReader(filename,Encoding.Default);
            result = Int32.TryParse(sr.ReadLine(), out checkerOfType);
            if (!result)
            {
                sr.Close();
                sr = new StreamReader(filename, Encoding.Default);
            }
            while (!sr.EndOfStream)
            {
                
                question = sr.ReadLine();
                if (result)
                {
                    ListOfAnswers = new Answers[checkerOfType];
                    goto FixedAnswers;
                }
                ListOfAnswers = new Answers[int.Parse(sr.ReadLine())];
            FixedAnswers:
                for (int i = 0; i < ListOfAnswers.Length; i++)
                {
                    ListOfAnswers[i] = new Answers(sr.ReadLine(), false);
                }
                ListOfAnswers[0].IsCorrect = true;
                Data.ListOfQuestions.Add(new Question(question, ListOfAnswers));
            }
            sr.Close();
        }
    }
}
    

